import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
//引入element-ui
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
//引用自己的css文件
import '../src/assets/all.css'
//引入axios
import axios from 'axios'

Vue.config.productionTip = false
Vue.use(ElementUI);
//注册axios
Vue.prototype.$http = axios

//设置路由拦截
router.beforeEach((to, from, next) => {
    if (to.path === '/login') next();
    else {
        const user = window.sessionStorage.getItem("user");
        if (user) next();
        else next("/login");
    }
});


new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')